home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / layout / nsStyleStruct.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  44KB  |  1,399 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is mozilla.org code.
  16.  *
  17.  * The Initial Developer of the Original Code is
  18.  * Netscape Communications Corporation.
  19.  * Portions created by the Initial Developer are Copyright (C) 1998
  20.  * the Initial Developer. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *   Mats Palmgren <mats.palmgren@bredband.net>
  24.  *
  25.  * Alternatively, the contents of this file may be used under the terms of
  26.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  27.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28.  * in which case the provisions of the GPL or the LGPL are applicable instead
  29.  * of those above. If you wish to allow use of your version of this file only
  30.  * under the terms of either the GPL or the LGPL, and not to allow others to
  31.  * use your version of this file under the terms of the MPL, indicate your
  32.  * decision by deleting the provisions above and replace them with the notice
  33.  * and other provisions required by the GPL or the LGPL. If you do not delete
  34.  * the provisions above, a recipient may use your version of this file under
  35.  * the terms of any one of the MPL, the GPL or the LGPL.
  36.  *
  37.  * ***** END LICENSE BLOCK ***** */
  38. #ifndef nsStyleStruct_h___
  39. #define nsStyleStruct_h___
  40.  
  41. #include "nsColor.h"
  42. #include "nsCoord.h"
  43. #include "nsMargin.h"
  44. #include "nsRect.h"
  45. #include "nsFont.h"
  46. #include "nsVoidArray.h"
  47. #include "nsStyleCoord.h"
  48. #include "nsStyleConsts.h"
  49. #include "nsChangeHint.h"
  50. #include "nsPresContext.h"
  51. #include "nsIPresShell.h"
  52. #include "nsCOMPtr.h"
  53. #include "nsCOMArray.h"
  54. #include "nsIAtom.h"
  55. #include "nsIURI.h"
  56. #include "nsCSSValue.h"
  57.  
  58. class nsIFrame;
  59. class imgIRequest;
  60.  
  61. enum nsStyleStructID {
  62.  
  63. /*
  64.  * Define the constants eStyleStruct_Font, etc.
  65.  *
  66.  * The C++ standard, section 7.2, guarantees that enums begin with 0 and
  67.  * increase by 1.
  68.  */
  69.  
  70. #define STYLE_STRUCT(name, checkdata_cb, ctor_args) eStyleStruct_##name,
  71. #include "nsStyleStructList.h"
  72. #undef STYLE_STRUCT
  73.  
  74. nsStyleStructID_Length /* one past the end; length of 0-based list */
  75.  
  76. };
  77.  
  78. // Bits for each struct.
  79. #define NS_STYLE_INHERIT_BIT(sid_)        (1 << PRInt32(eStyleStruct_##sid_))
  80. #define NS_STYLE_INHERIT_MASK             0x00ffffff
  81.  
  82. // Additional bits for nsStyleContext's mBits:
  83. // A bit to test whether or not we have any text decorations.
  84. #define NS_STYLE_HAS_TEXT_DECORATIONS     0x01000000
  85.  
  86. // Additional bits for nsRuleNode's mDependentBits:
  87. #define NS_RULE_NODE_GC_MARK              0x02000000
  88.  
  89. #define NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(the_sid) \
  90.   static nsStyleStructID GetStyleStructID() {return the_sid;}
  91.  
  92. #define NS_GET_STYLESTRUCTID(type) (type::GetStyleStructID())
  93.  
  94. // The actual structs start here
  95. struct nsStyleStruct {
  96. };
  97.  
  98. // The lifetime of these objects is managed by the presshell's arena.
  99.  
  100. struct nsStyleFont : public nsStyleStruct {
  101.   nsStyleFont(void);
  102.   nsStyleFont(const nsFont& aFont);
  103.   nsStyleFont(const nsStyleFont& aStyleFont);
  104.   nsStyleFont(nsPresContext *aPresContext);
  105.   ~nsStyleFont(void) {};
  106.  
  107.   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Font)
  108.  
  109.   nsChangeHint CalcDifference(const nsStyleFont& aOther) const;
  110. #ifdef DEBUG
  111.   static nsChangeHint MaxDifference();
  112. #endif
  113.   static nsChangeHint CalcFontDifference(const nsFont& aFont1, const nsFont& aFont2);
  114.  
  115.   static nscoord ZoomText(nsPresContext* aPresContext, nscoord aSize);
  116.   static nscoord UnZoomText(nsPresContext* aPresContext, nscoord aSize);
  117.   
  118.   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW;
  119.   void Destroy(nsPresContext* aContext);
  120.  
  121.   PRUint8 mFlags;       // [inherited] See nsStyleConsts.h
  122.   nsFont  mFont;        // [inherited]
  123.   nscoord mSize;        // [inherited] Our "computed size". Can be different from mFont.size
  124.                         // which is our "actual size" and is enforced to be >= the user's
  125.                         // preferred min-size. mFont.size should be used for display purposes
  126.                         // while mSize is the value to return in getComputedStyle() for example.
  127. };
  128.  
  129. struct nsStyleColor : public nsStyleStruct {
  130.   nsStyleColor(nsPresContext* aPresContext);
  131.   nsStyleColor(const nsStyleColor& aOther);
  132.   ~nsStyleColor(void) {};
  133.  
  134.   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Color)
  135.  
  136.   nsChangeHint CalcDifference(const nsStyleColor& aOther) const;
  137. #ifdef DEBUG
  138.   static nsChangeHint MaxDifference();
  139. #endif
  140.   
  141.   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
  142.     return aContext->AllocateFromShell(sz);
  143.   }
  144.   void Destroy(nsPresContext* aContext) {
  145.     this->~nsStyleColor();
  146.     aContext->FreeToShell(sizeof(nsStyleColor), this);
  147.   };
  148.  
  149.   // Don't add ANY members to this struct!  We can achieve caching in the rule
  150.   // tree (rather than the style tree) by letting color stay by itself! -dwh
  151.   nscolor mColor;                 // [inherited]
  152. };
  153.  
  154. struct nsStyleBackground : public nsStyleStruct {
  155.   nsStyleBackground(nsPresContext* aPresContext);
  156.   nsStyleBackground(const nsStyleBackground& aOther);
  157.   ~nsStyleBackground();
  158.  
  159.   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Background)
  160.  
  161.   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
  162.     return aContext->AllocateFromShell(sz);
  163.   }
  164.   void Destroy(nsPresContext* aContext) {
  165.     this->~nsStyleBackground();
  166.     aContext->FreeToShell(sizeof(nsStyleBackground), this);
  167.   };
  168.  
  169.   nsChangeHint CalcDifference(const nsStyleBackground& aOther) const;
  170. #ifdef DEBUG
  171.   static nsChangeHint MaxDifference();
  172. #endif
  173.  
  174.   // On Linux (others?), there is an extra byte being used up by
  175.   // inheritance so we only have 3 bytes to fit these 6 things into.
  176.   // Fortunately, the properties are enums which have few possible
  177.   // values.
  178.   PRUint8 mBackgroundFlags;            // [reset] See nsStyleConsts.h
  179.   PRUint8 mBackgroundAttachment   : 4; // [reset] See nsStyleConsts.h
  180.   PRUint8 mBackgroundClip         : 3; // [reset] See nsStyleConsts.h
  181.   PRUint8 mBackgroundInlinePolicy : 2; // [reset] See nsStyleConsts.h
  182.   PRUint8 mBackgroundOrigin       : 3; // [reset] See nsStyleConsts.h
  183.   PRUint8 mBackgroundRepeat       : 4; // [reset] See nsStyleConsts.h
  184.  
  185.   // Note: a member of this union is valid IFF the appropriate bit flag
  186.   // is set in mBackgroundFlags.
  187.   union {
  188.     nscoord mCoord;
  189.     float   mFloat;
  190.   } mBackgroundXPosition,         // [reset]
  191.     mBackgroundYPosition;         // [reset]
  192.  
  193.   nscolor mBackgroundColor;       // [reset]
  194.   nsCOMPtr<imgIRequest> mBackgroundImage; // [reset]
  195.  
  196.   PRBool IsTransparent() const
  197.   {
  198.     return (mBackgroundFlags &
  199.             (NS_STYLE_BG_COLOR_TRANSPARENT | NS_STYLE_BG_IMAGE_NONE)) ==
  200.             (NS_STYLE_BG_COLOR_TRANSPARENT | NS_STYLE_BG_IMAGE_NONE);
  201.   }
  202.  
  203.   // We have to take slower codepaths for fixed background attachment,
  204.   // but we don't want to do that when there's no image.
  205.   // Not inline because it uses an nsCOMPtr<imgIRequest>
  206.   PRBool HasFixedBackground() const;
  207. };
  208.  
  209. #define BORDER_COLOR_TRANSPARENT  0x40
  210. #define BORDER_COLOR_FOREGROUND   0x20
  211. #define BORDER_COLOR_SPECIAL      0x60 // TRANSPARENT | FOREGROUND 
  212. #define BORDER_STYLE_MASK         0x1F
  213.  
  214. #define NS_SPACING_MARGIN   0
  215. #define NS_SPACING_PADDING  1
  216. #define NS_SPACING_BORDER   2
  217.  
  218.  
  219. struct nsStyleMargin: public nsStyleStruct {
  220.   nsStyleMargin(void);
  221.   nsStyleMargin(const nsStyleMargin& aMargin);
  222.   ~nsStyleMargin(void) {};
  223.  
  224.   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Margin)
  225.  
  226.   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW;
  227.   void Destroy(nsPresContext* aContext);
  228.  
  229.   void RecalcData();
  230.   nsChangeHint CalcDifference(const nsStyleMargin& aOther) const;
  231. #ifdef DEBUG
  232.   static nsChangeHint MaxDifference();
  233. #endif
  234.  
  235.   nsStyleSides  mMargin;          // [reset] length, percent, auto, inherit
  236.  
  237.   PRBool GetMargin(nsMargin& aMargin) const
  238.   {
  239.     if (mHasCachedMargin) {
  240.       aMargin = mCachedMargin;
  241.       return PR_TRUE;
  242.     }
  243.     return PR_FALSE;
  244.   }
  245.  
  246.   // XXX this is a deprecated method
  247.   void CalcMarginFor(const nsIFrame* aFrame, nsMargin& aMargin) const;
  248.  
  249. protected:
  250.   PRPackedBool  mHasCachedMargin;
  251.   nsMargin      mCachedMargin;
  252. };
  253.  
  254.  
  255. struct nsStylePadding: public nsStyleStruct {
  256.   nsStylePadding(void);
  257.   nsStylePadding(const nsStylePadding& aPadding);
  258.   ~nsStylePadding(void) {};
  259.  
  260.   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Padding)
  261.  
  262.   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW;
  263.   void Destroy(nsPresContext* aContext);
  264.  
  265.   void RecalcData();
  266.   nsChangeHint CalcDifference(const nsStylePadding& aOther) const;
  267. #ifdef DEBUG
  268.   static nsChangeHint MaxDifference();
  269. #endif
  270.   
  271.   nsStyleSides  mPadding;         // [reset] length, percent, inherit
  272.  
  273.   PRBool GetPadding(nsMargin& aPadding) const
  274.   {
  275.     if (mHasCachedPadding) {
  276.       aPadding = mCachedPadding;
  277.       return PR_TRUE;
  278.     }
  279.     return PR_FALSE;
  280.   }
  281.  
  282.   // XXX this is a deprecated method
  283.   void CalcPaddingFor(const nsIFrame* aFrame, nsMargin& aPadding) const;
  284.   
  285. protected:
  286.   PRPackedBool  mHasCachedPadding;
  287.   nsMargin      mCachedPadding;
  288. };
  289.  
  290. struct nsBorderColors {
  291.   nsBorderColors* mNext;
  292.   nscolor mColor;
  293.   PRBool mTransparent;
  294.  
  295.   nsBorderColors* CopyColors() {
  296.     nsBorderColors* next = nsnull;
  297.     if (mNext)
  298.       next = mNext->CopyColors();
  299.     return new nsBorderColors(mColor, mTransparent, next);
  300.   }
  301.  
  302.   nsBorderColors() :mNext(nsnull) { mColor = NS_RGB(0,0,0); };
  303.  
  304.   nsBorderColors(const nscolor& aColor, PRBool aTransparent, nsBorderColors* aNext=nsnull) {
  305.     mColor = aColor;
  306.     mTransparent = aTransparent;
  307.     mNext = aNext;
  308.   }
  309.  
  310.   ~nsBorderColors() {
  311.     delete mNext;
  312.   }
  313.  
  314.   PRBool Equals(nsBorderColors* aOther) {
  315.     nsBorderColors* c1 = this;
  316.     nsBorderColors* c2 = aOther;
  317.     while (c1 && c2) {
  318.       if (c1->mColor != c2->mColor ||
  319.           c1->mTransparent != c2->mTransparent)
  320.         return PR_FALSE;
  321.       c1 = c1->mNext;
  322.       c2 = c2->mNext;
  323.     }
  324.     return !c1 && !c2;
  325.   }
  326. };
  327.  
  328. struct nsStyleBorder: public nsStyleStruct {
  329.   nsStyleBorder() :mBorderColors(nsnull) {};
  330.   nsStyleBorder(nsPresContext* aContext);
  331.   nsStyleBorder(const nsStyleBorder& aBorder);
  332.   ~nsStyleBorder(void) {
  333.     if (mBorderColors) {
  334.       for (PRInt32 i = 0; i < 4; i++)
  335.         delete mBorderColors[i];
  336.       delete []mBorderColors;
  337.     }
  338.   };
  339.  
  340.   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Border)
  341.  
  342.   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW;
  343.   void Destroy(nsPresContext* aContext);
  344.  
  345.   nsChangeHint CalcDifference(const nsStyleBorder& aOther) const;
  346. #ifdef DEBUG
  347.   static nsChangeHint MaxDifference();
  348. #endif
  349.  
  350.   nsStyleSides  mBorderRadius;    // [reset] length, percent, inherit
  351.   PRUint8       mFloatEdge;       // [reset] see nsStyleConsts.h
  352.   nsBorderColors** mBorderColors; // [reset] multiple levels of color for a border.
  353.  
  354.   void EnsureBorderColors() {
  355.     if (!mBorderColors) {
  356.       mBorderColors = new nsBorderColors*[4];
  357.       if (mBorderColors)
  358.         for (PRInt32 i = 0; i < 4; i++)
  359.           mBorderColors[i] = nsnull;
  360.     }
  361.   }
  362.  
  363.   void ClearBorderColors(PRUint8 aSide) {
  364.     if (mBorderColors[aSide]) {
  365.       delete mBorderColors[aSide];
  366.       mBorderColors[aSide] = nsnull;
  367.     }
  368.   }
  369.  
  370.   // Return whether aStyle is a visible style.  Invisible styles cause
  371.   // the relevant computed border width to be 0.
  372.   static PRBool IsVisibleStyle(PRUint8 aStyle) {
  373.     return aStyle != NS_STYLE_BORDER_STYLE_NONE &&
  374.            aStyle != NS_STYLE_BORDER_STYLE_HIDDEN;
  375.   }
  376.  
  377.   // aBorderWidth is in twips
  378.   void SetBorderWidth(PRUint8 aSide, nscoord aBorderWidth)
  379.   {
  380.     mBorder.side(aSide) = aBorderWidth;
  381.     if (IsVisibleStyle(GetBorderStyle(aSide))) {
  382.       mComputedBorder.side(aSide) = aBorderWidth;
  383.     }
  384.   }
  385.  
  386.   // Get the computed border, in twips.
  387.   const nsMargin& GetBorder() const
  388.   {
  389.     return mComputedBorder;
  390.   }
  391.  
  392.   // Get the computed border width for a particular side, in twips.  Note that
  393.   // this is zero if and only if there is no border to be painted for this
  394.   // side.  That is, this value takes into account the border style.
  395.   nscoord GetBorderWidth(PRUint8 aSide) const
  396.   {
  397.     return mComputedBorder.side(aSide);
  398.   }
  399.  
  400.   PRUint8 GetBorderStyle(PRUint8 aSide) const
  401.   {
  402.     NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side"); 
  403.     return (mBorderStyle[aSide] & BORDER_STYLE_MASK); 
  404.   }
  405.  
  406.   void SetBorderStyle(PRUint8 aSide, PRUint8 aStyle)
  407.   {
  408.     NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side"); 
  409.     mBorderStyle[aSide] &= ~BORDER_STYLE_MASK; 
  410.     mBorderStyle[aSide] |= (aStyle & BORDER_STYLE_MASK);
  411.     if (IsVisibleStyle(aStyle)) {
  412.       mComputedBorder.side(aSide) = mBorder.side(aSide);
  413.     } else {
  414.       mComputedBorder.side(aSide) = 0;
  415.     }
  416.   }
  417.  
  418.   void GetBorderColor(PRUint8 aSide, nscolor& aColor,
  419.                       PRBool& aTransparent, PRBool& aForeground) const
  420.   {
  421.     aTransparent = aForeground = PR_FALSE;
  422.     NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side"); 
  423.     if ((mBorderStyle[aSide] & BORDER_COLOR_SPECIAL) == 0)
  424.       aColor = mBorderColor[aSide]; 
  425.     else if (mBorderStyle[aSide] & BORDER_COLOR_FOREGROUND)
  426.       aForeground = PR_TRUE;
  427.     else
  428.       aTransparent = PR_TRUE;
  429.   }
  430.  
  431.   void SetBorderColor(PRUint8 aSide, nscolor aColor) 
  432.   {
  433.     NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side"); 
  434.     mBorderColor[aSide] = aColor; 
  435.     mBorderStyle[aSide] &= ~BORDER_COLOR_SPECIAL;
  436.   }
  437.  
  438.   void GetCompositeColors(PRInt32 aIndex, nsBorderColors** aColors) const
  439.   {
  440.     if (!mBorderColors)
  441.       *aColors = nsnull;
  442.     else
  443.       *aColors = mBorderColors[aIndex];
  444.   }
  445.  
  446.   void AppendBorderColor(PRInt32 aIndex, nscolor aColor, PRBool aTransparent)
  447.   {
  448.     NS_ASSERTION(aIndex >= 0 && aIndex <= 3, "bad side for composite border color");
  449.     nsBorderColors* colorEntry = new nsBorderColors(aColor, aTransparent);
  450.     if (!mBorderColors[aIndex])
  451.       mBorderColors[aIndex] = colorEntry;
  452.     else {
  453.       nsBorderColors* last = mBorderColors[aIndex];
  454.       while (last->mNext)
  455.         last = last->mNext;
  456.       last->mNext = colorEntry;
  457.     }
  458.     mBorderStyle[aIndex] &= ~BORDER_COLOR_SPECIAL;
  459.   }
  460.  
  461.   void SetBorderTransparent(PRUint8 aSide)
  462.   {
  463.     NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side"); 
  464.     mBorderStyle[aSide] &= ~BORDER_COLOR_SPECIAL;
  465.     mBorderStyle[aSide] |= BORDER_COLOR_TRANSPARENT; 
  466.   }
  467.  
  468.   void SetBorderToForeground(PRUint8 aSide)
  469.   {
  470.     NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side"); 
  471.     mBorderStyle[aSide] &= ~BORDER_COLOR_SPECIAL;
  472.     mBorderStyle[aSide] |= BORDER_COLOR_FOREGROUND; 
  473.   }
  474.  
  475.   // XXX these are deprecated methods
  476.   void CalcBorderFor(const nsIFrame* aFrame, nsMargin& aBorder) const
  477.   {
  478.     aBorder = GetBorder();
  479.   }
  480.   void CalcBorderFor(const nsIFrame* aFrame, PRUint8 aSide,
  481.                      nscoord& aWidth) const {
  482.     aWidth = GetBorderWidth(aSide);
  483.   }
  484.   
  485. protected:
  486.   // mComputedBorder holds the CSS2.1 computed border-width values.  In
  487.   // particular, these widths take into account the border-style for the
  488.   // relevant side.
  489.   nsMargin      mComputedBorder;
  490.  
  491.   // mBorder holds the nscoord values for the border widths as they would be if
  492.   // all the border-style values were visible (not hidden or none).  This
  493.   // member exists solely so that when we create structs using the copy
  494.   // constructor during style resolution the new structs will know what the
  495.   // specified values of the border were in case they have more specific rules
  496.   // setting the border style.  Note that this isn't quite the CSS specified
  497.   // value, since this has had the enumerated border widths converted to
  498.   // lengths, and all lengths converted to twips.  But it's not quite the
  499.   // computed value either; mComputedBorder is that.
  500.   nsMargin      mBorder;
  501.  
  502.   PRUint8       mBorderStyle[4];  // [reset] See nsStyleConsts.h
  503.   nscolor       mBorderColor[4];  // [reset] the colors to use for a simple border.  not used
  504.                                   // if -moz-border-colors is specified
  505. };
  506.  
  507.  
  508. struct nsStyleBorderPadding: public nsStyleStruct {
  509.   nsStyleBorderPadding(void) { mHasCachedBorderPadding = PR_FALSE; };
  510.   ~nsStyleBorderPadding(void) {};
  511.  
  512.   // No accessor for this struct, since it's not a real struct.  At
  513.   // least not for now...
  514.  
  515.   PRBool GetBorderPadding(nsMargin& aBorderPadding) const {
  516.     if (mHasCachedBorderPadding) {
  517.       aBorderPadding = mCachedBorderPadding;
  518.       return PR_TRUE;
  519.     }
  520.     return PR_FALSE;
  521.   }
  522.  
  523.   void SetBorderPadding(nsMargin aBorderPadding) {
  524.     mCachedBorderPadding = aBorderPadding;
  525.     mHasCachedBorderPadding = PR_TRUE;
  526.   }
  527.  
  528. protected:
  529.   nsMargin      mCachedBorderPadding;
  530.   PRPackedBool  mHasCachedBorderPadding;
  531. };
  532.  
  533.  
  534. struct nsStyleOutline: public nsStyleStruct {
  535.   nsStyleOutline(nsPresContext* aPresContext);
  536.   nsStyleOutline(const nsStyleOutline& aOutline);
  537.   ~nsStyleOutline(void) {};
  538.  
  539.   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Outline)
  540.  
  541.   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
  542.     return aContext->AllocateFromShell(sz);
  543.   }
  544.   void Destroy(nsPresContext* aContext) {
  545.     this->~nsStyleOutline();
  546.     aContext->FreeToShell(sizeof(nsStyleOutline), this);
  547.   };
  548.  
  549.   void RecalcData(nsPresContext* aContext);
  550.   nsChangeHint CalcDifference(const nsStyleOutline& aOther) const;
  551. #ifdef DEBUG
  552.   static nsChangeHint MaxDifference();
  553. #endif
  554.  
  555.   nsStyleSides  mOutlineRadius;    // [reset] length, percent, inherit
  556.                                                                   // (top=topLeft, right=topRight, bottom=bottomRight, left=bottomLeft)
  557.  
  558.   nsStyleCoord  mOutlineOffset;   // [reset] length
  559.   nsStyleCoord  mOutlineWidth;    // [reset] length, enum (see nsStyleConsts.h)
  560.  
  561.   PRBool GetOutlineOffset(nscoord& aOffset) const
  562.   {
  563.     if (mOutlineOffset.GetUnit() == eStyleUnit_Coord) {
  564.       aOffset = mOutlineOffset.GetCoordValue();
  565.       return PR_TRUE;
  566.     } else {
  567.       NS_NOTYETIMPLEMENTED("GetOutlineOffset: eStyleUnit_Chars");
  568.       aOffset = 0;
  569.       return PR_FALSE;
  570.     }
  571.   }
  572.  
  573.   PRBool GetOutlineWidth(nscoord& aWidth) const
  574.   {
  575.     if (mHasCachedOutline) {
  576.       aWidth = mCachedOutlineWidth;
  577.       return PR_TRUE;
  578.     }
  579.     return PR_FALSE;
  580.   }
  581.  
  582.   PRUint8 GetOutlineStyle(void) const
  583.   {
  584.     return (mOutlineStyle & BORDER_STYLE_MASK);
  585.   }
  586.  
  587.   void SetOutlineStyle(PRUint8 aStyle)
  588.   {
  589.     mOutlineStyle &= ~BORDER_STYLE_MASK;
  590.     mOutlineStyle |= (aStyle & BORDER_STYLE_MASK);
  591.   }
  592.  
  593.   // PR_FALSE means INVERT 
  594.   PRBool GetOutlineColor(nscolor& aColor) const
  595.   {
  596.     if ((mOutlineStyle & BORDER_COLOR_SPECIAL) == 0) {
  597.       aColor = mOutlineColor;
  598.       return PR_TRUE;
  599.     }
  600.     return PR_FALSE;
  601.   }
  602.  
  603.   void SetOutlineColor(nscolor aColor)
  604.   {
  605.     mOutlineColor = aColor;
  606.     mOutlineStyle &= ~BORDER_COLOR_SPECIAL;
  607.   }
  608.  
  609.   void SetOutlineInvert(void)
  610.   {
  611.     mOutlineStyle |= BORDER_COLOR_SPECIAL;
  612.   }
  613.  
  614.   PRBool  GetOutlineInvert(void) const
  615.   {
  616.     return(mOutlineStyle & BORDER_COLOR_SPECIAL);
  617.   }
  618.  
  619. protected:
  620.   nscoord       mCachedOutlineWidth;
  621.  
  622.   nscolor       mOutlineColor;    // [reset] 
  623.  
  624.   PRPackedBool  mHasCachedOutline;
  625.   PRUint8       mOutlineStyle;    // [reset] See nsStyleConsts.h
  626. };
  627.  
  628.  
  629. struct nsStyleList : public nsStyleStruct {
  630.   nsStyleList(void);
  631.   nsStyleList(const nsStyleList& aStyleList);
  632.   ~nsStyleList(void);
  633.  
  634.   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_List)
  635.  
  636.   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
  637.     return aContext->AllocateFromShell(sz);
  638.   }
  639.   void Destroy(nsPresContext* aContext) {
  640.     this->~nsStyleList();
  641.     aContext->FreeToShell(sizeof(nsStyleList), this);
  642.   };
  643.  
  644.   nsChangeHint CalcDifference(const nsStyleList& aOther) const;
  645. #ifdef DEBUG
  646.   static nsChangeHint MaxDifference();
  647. #endif
  648.   
  649.   PRUint8   mListStyleType;             // [inherited] See nsStyleConsts.h
  650.   PRUint8   mListStylePosition;         // [inherited] 
  651.   nsCOMPtr<imgIRequest> mListStyleImage; // [inherited]
  652.   nsRect        mImageRegion;           // [inherited] the rect to use within an image  
  653. };
  654.  
  655. struct nsStylePosition : public nsStyleStruct {
  656.   nsStylePosition(void);
  657.   nsStylePosition(const nsStylePosition& aOther);
  658.   ~nsStylePosition(void);
  659.  
  660.   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Position)
  661.  
  662.   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
  663.     return aContext->AllocateFromShell(sz);
  664.   }
  665.   void Destroy(nsPresContext* aContext) {
  666.     this->~nsStylePosition();
  667.     aContext->FreeToShell(sizeof(nsStylePosition), this);
  668.   };
  669.  
  670.   nsChangeHint CalcDifference(const nsStylePosition& aOther) const;
  671. #ifdef DEBUG
  672.   static nsChangeHint MaxDifference();
  673. #endif
  674.   
  675.   nsStyleSides  mOffset;                // [reset]
  676.   nsStyleCoord  mWidth;                 // [reset] coord, percent, auto, inherit
  677.   nsStyleCoord  mMinWidth;              // [reset] coord, percent, inherit
  678.   nsStyleCoord  mMaxWidth;              // [reset] coord, percent, null, inherit
  679.   nsStyleCoord  mHeight;                // [reset] coord, percent, auto, inherit
  680.   nsStyleCoord  mMinHeight;             // [reset] coord, percent, inherit
  681.   nsStyleCoord  mMaxHeight;             // [reset] coord, percent, null, inherit
  682.   PRUint8       mBoxSizing;             // [reset] see nsStyleConsts.h
  683.   nsStyleCoord  mZIndex;                // [reset] 
  684. };
  685.  
  686. struct nsStyleTextReset : public nsStyleStruct {
  687.   nsStyleTextReset(void);
  688.   nsStyleTextReset(const nsStyleTextReset& aOther);
  689.   ~nsStyleTextReset(void);
  690.  
  691.   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_TextReset)
  692.  
  693.   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
  694.     return aContext->AllocateFromShell(sz);
  695.   }
  696.   void Destroy(nsPresContext* aContext) {
  697.     this->~nsStyleTextReset();
  698.     aContext->FreeToShell(sizeof(nsStyleTextReset), this);
  699.   };
  700.  
  701.   nsChangeHint CalcDifference(const nsStyleTextReset& aOther) const;
  702. #ifdef DEBUG
  703.   static nsChangeHint MaxDifference();
  704. #endif
  705.   
  706.   PRUint8 mTextDecoration;              // [reset] see nsStyleConsts.h
  707.   PRUint8 mUnicodeBidi;                 // [reset] see nsStyleConsts.h
  708.  
  709.   nsStyleCoord  mVerticalAlign;         // [reset] see nsStyleConsts.h for enums
  710. };
  711.  
  712. struct nsStyleText : public nsStyleStruct {
  713.   nsStyleText(void);
  714.   nsStyleText(const nsStyleText& aOther);
  715.   ~nsStyleText(void);
  716.  
  717.   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Text)
  718.  
  719.   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
  720.     return aContext->AllocateFromShell(sz);
  721.   }
  722.   void Destroy(nsPresContext* aContext) {
  723.     this->~nsStyleText();
  724.     aContext->FreeToShell(sizeof(nsStyleText), this);
  725.   };
  726.  
  727.   nsChangeHint CalcDifference(const nsStyleText& aOther) const;
  728. #ifdef DEBUG
  729.   static nsChangeHint MaxDifference();
  730. #endif
  731.  
  732.   PRUint8 mTextAlign;                   // [inherited] see nsStyleConsts.h
  733.   PRUint8 mTextTransform;               // [inherited] see nsStyleConsts.h
  734.   PRUint8 mWhiteSpace;                  // [inherited] see nsStyleConsts.h
  735.  
  736.   nsStyleCoord  mLetterSpacing;         // [inherited] 
  737.   nsStyleCoord  mLineHeight;            // [inherited] 
  738.   nsStyleCoord  mTextIndent;            // [inherited] 
  739.   nsStyleCoord  mWordSpacing;           // [inherited] 
  740.   
  741.   PRBool WhiteSpaceIsSignificant() const {
  742.     return mWhiteSpace == NS_STYLE_WHITESPACE_PRE ||
  743.            mWhiteSpace == NS_STYLE_WHITESPACE_MOZ_PRE_WRAP;
  744.   }
  745. };
  746.  
  747. struct nsStyleVisibility : public nsStyleStruct {
  748.   nsStyleVisibility(nsPresContext* aPresContext);
  749.   nsStyleVisibility(const nsStyleVisibility& aVisibility);
  750.   ~nsStyleVisibility() {};
  751.  
  752.   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Visibility)
  753.  
  754.   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
  755.     return aContext->AllocateFromShell(sz);
  756.   }
  757.   void Destroy(nsPresContext* aContext) {
  758.     this->~nsStyleVisibility();
  759.     aContext->FreeToShell(sizeof(nsStyleVisibility), this);
  760.   };
  761.  
  762.   nsChangeHint CalcDifference(const nsStyleVisibility& aOther) const;
  763. #ifdef DEBUG
  764.   static nsChangeHint MaxDifference();
  765. #endif
  766.   
  767.   PRUint8 mDirection;                  // [inherited] see nsStyleConsts.h NS_STYLE_DIRECTION_*
  768.   PRUint8   mVisible;                  // [inherited]
  769.   nsCOMPtr<nsIAtom> mLangGroup;        // [inherited]
  770.  
  771.   PRBool IsVisible() const {
  772.         return (mVisible == NS_STYLE_VISIBILITY_VISIBLE);
  773.     }
  774.  
  775.     PRBool IsVisibleOrCollapsed() const {
  776.         return ((mVisible == NS_STYLE_VISIBILITY_VISIBLE) ||
  777.                         (mVisible == NS_STYLE_VISIBILITY_COLLAPSE));
  778.     }
  779. };
  780.  
  781. struct nsStyleDisplay : public nsStyleStruct {
  782.   nsStyleDisplay();
  783.   nsStyleDisplay(const nsStyleDisplay& aOther); 
  784.   ~nsStyleDisplay() {};
  785.  
  786.   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Display)
  787.  
  788.   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
  789.     return aContext->AllocateFromShell(sz);
  790.   }
  791.   void Destroy(nsPresContext* aContext) {
  792.     this->~nsStyleDisplay();
  793.     aContext->FreeToShell(sizeof(nsStyleDisplay), this);
  794.   };
  795.  
  796.   nsChangeHint CalcDifference(const nsStyleDisplay& aOther) const;
  797. #ifdef DEBUG
  798.   static nsChangeHint MaxDifference();
  799. #endif
  800.   
  801.   nsCOMPtr<nsIURI> mBinding;    // [reset]
  802. #if 0
  803.   // XXX This is how it is defined in the CSS2 spec, but the errata
  804.   // changed it to be consistent with the positioning draft and how
  805.   // Nav and IE implement it
  806.   nsMargin  mClip;              // [reset] offsets from respective edge
  807. #else
  808.   nsRect    mClip;              // [reset] offsets from upper-left border edge
  809. #endif
  810.   float   mOpacity;             // [reset]
  811.   PRUint8 mDisplay;             // [reset] see nsStyleConsts.h NS_STYLE_DISPLAY_*
  812.   PRUint8 mOriginalDisplay;     // [reset] saved mDisplay for position:absolute/fixed
  813.   PRUint8 mAppearance;          // [reset]
  814.   PRUint8 mPosition;            // [reset] see nsStyleConsts.h
  815.   PRUint8 mFloats;              // [reset] see nsStyleConsts.h NS_STYLE_FLOAT_*
  816.   PRUint8 mBreakType;           // [reset] see nsStyleConsts.h NS_STYLE_CLEAR_*
  817.   PRPackedBool mBreakBefore;    // [reset] 
  818.   PRPackedBool mBreakAfter;     // [reset] 
  819.   PRUint8 mOverflowX;           // [reset] see nsStyleConsts.h
  820.   PRUint8 mOverflowY;           // [reset] see nsStyleConsts.h
  821.   PRUint8   mClipFlags;         // [reset] see nsStyleConsts.h
  822.   
  823.   PRBool IsBlockLevel() const {return (NS_STYLE_DISPLAY_BLOCK == mDisplay) ||
  824.                                       (NS_STYLE_DISPLAY_LIST_ITEM == mDisplay) ||
  825.                                       (NS_STYLE_DISPLAY_TABLE == mDisplay);}
  826.  
  827.   PRBool IsFloating() const {
  828.     return NS_STYLE_FLOAT_NONE != mFloats;
  829.   }
  830.  
  831.   PRBool IsAbsolutelyPositioned() const {return (NS_STYLE_POSITION_ABSOLUTE == mPosition) ||
  832.                                                 (NS_STYLE_POSITION_FIXED == mPosition);}
  833.  
  834.   PRBool IsPositioned() const {return IsAbsolutelyPositioned() ||
  835.                                       (NS_STYLE_POSITION_RELATIVE == mPosition);}
  836.  
  837.   PRBool IsScrollableOverflow() const {
  838.     // mOverflowX and mOverflowY always match when one of them is
  839.     // NS_STYLE_OVERFLOW_VISIBLE or NS_STYLE_OVERFLOW_CLIP.
  840.     return mOverflowX != NS_STYLE_OVERFLOW_VISIBLE &&
  841.            mOverflowX != NS_STYLE_OVERFLOW_CLIP;
  842.   }
  843.  
  844.   // For table elements that don't support scroll frame creation, we
  845.   // support 'overflow: hidden' to mean 'overflow: -moz-hidden-unscrollable'.
  846.   PRBool IsTableClip() const {
  847.     return mOverflowX == NS_STYLE_OVERFLOW_CLIP ||
  848.            (mOverflowX == NS_STYLE_OVERFLOW_HIDDEN &&
  849.             mOverflowY == NS_STYLE_OVERFLOW_HIDDEN);
  850.   }
  851. };
  852.  
  853. struct nsStyleTable: public nsStyleStruct {
  854.   nsStyleTable(void);
  855.   nsStyleTable(const nsStyleTable& aOther);
  856.   ~nsStyleTable(void);
  857.  
  858.   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Table)
  859.  
  860.   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
  861.     return aContext->AllocateFromShell(sz);
  862.   }
  863.   void Destroy(nsPresContext* aContext) {
  864.     this->~nsStyleTable();
  865.     aContext->FreeToShell(sizeof(nsStyleTable), this);
  866.   };
  867.  
  868.   nsChangeHint CalcDifference(const nsStyleTable& aOther) const;
  869. #ifdef DEBUG
  870.   static nsChangeHint MaxDifference();
  871. #endif
  872.   
  873.   PRUint8       mLayoutStrategy;// [reset] see nsStyleConsts.h NS_STYLE_TABLE_LAYOUT_*
  874.   PRUint8       mFrame;         // [reset] see nsStyleConsts.h NS_STYLE_TABLE_FRAME_*
  875.   PRUint8       mRules;         // [reset] see nsStyleConsts.h NS_STYLE_TABLE_RULES_*
  876.   PRInt32       mCols;          // [reset] an integer if set, or see nsStyleConsts.h NS_STYLE_TABLE_COLS_*
  877.   PRInt32       mSpan;          // [reset] the number of columns spanned by a colgroup or col
  878. };
  879.  
  880. struct nsStyleTableBorder: public nsStyleStruct {
  881.   nsStyleTableBorder(nsPresContext* aContext);
  882.   nsStyleTableBorder(const nsStyleTableBorder& aOther);
  883.   ~nsStyleTableBorder(void);
  884.  
  885.   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_TableBorder)
  886.  
  887.   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
  888.     return aContext->AllocateFromShell(sz);
  889.   }
  890.   void Destroy(nsPresContext* aContext) {
  891.     this->~nsStyleTableBorder();
  892.     aContext->FreeToShell(sizeof(nsStyleTableBorder), this);
  893.   };
  894.  
  895.   nsChangeHint CalcDifference(const nsStyleTableBorder& aOther) const;
  896. #ifdef DEBUG
  897.   static nsChangeHint MaxDifference();
  898. #endif
  899.   
  900.   nsStyleCoord  mBorderSpacingX;// [inherited]
  901.   nsStyleCoord  mBorderSpacingY;// [inherited]
  902.   PRUint8       mBorderCollapse;// [inherited]
  903.   PRUint8       mCaptionSide;   // [inherited]
  904.   PRUint8       mEmptyCells;    // [inherited]
  905. };
  906.  
  907. enum nsStyleContentType {
  908.   eStyleContentType_String        = 1,
  909.   eStyleContentType_Image         = 10,
  910.   eStyleContentType_Attr          = 20,
  911.   eStyleContentType_Counter       = 30,
  912.   eStyleContentType_Counters      = 31,
  913.   eStyleContentType_OpenQuote     = 40,
  914.   eStyleContentType_CloseQuote    = 41,
  915.   eStyleContentType_NoOpenQuote   = 42,
  916.   eStyleContentType_NoCloseQuote  = 43
  917. };
  918.  
  919. struct nsStyleContentData {
  920.   nsStyleContentType  mType;
  921.   union {
  922.     PRUnichar *mString;
  923.     imgIRequest *mImage;
  924.     nsCSSValue::Array* mCounters;
  925.   } mContent;
  926.  
  927.   nsStyleContentData() : mType(nsStyleContentType(0)) { mContent.mString = nsnull; }
  928.   ~nsStyleContentData();
  929.   nsStyleContentData& operator=(const nsStyleContentData& aOther);
  930.   PRBool operator==(const nsStyleContentData& aOther);
  931.  
  932.   PRBool operator!=(const nsStyleContentData& aOther) {
  933.     return !(*this == aOther);
  934.   }
  935. private:
  936.   nsStyleContentData(const nsStyleContentData&); // not to be implemented
  937. };
  938.  
  939. struct nsStyleCounterData {
  940.   nsString  mCounter;
  941.   PRInt32   mValue;
  942. };
  943.  
  944.  
  945. #define DELETE_ARRAY_IF(array)  if (array) { delete[] array; array = nsnull; }
  946.  
  947. struct nsStyleQuotes : public nsStyleStruct {
  948.   nsStyleQuotes();
  949.   nsStyleQuotes(const nsStyleQuotes& aQuotes);
  950.   ~nsStyleQuotes();
  951.  
  952.   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Quotes)
  953.  
  954.   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
  955.     return aContext->AllocateFromShell(sz);
  956.   }
  957.   void Destroy(nsPresContext* aContext) {
  958.     this->~nsStyleQuotes();
  959.     aContext->FreeToShell(sizeof(nsStyleQuotes), this);
  960.   };
  961.  
  962.   nsChangeHint CalcDifference(const nsStyleQuotes& aOther) const;
  963. #ifdef DEBUG
  964.   static nsChangeHint MaxDifference();
  965. #endif
  966.   
  967.   PRUint32  QuotesCount(void) const { return mQuotesCount; } // [inherited]
  968.  
  969.   const nsString* OpenQuoteAt(PRUint32 aIndex) const
  970.   {
  971.     NS_ASSERTION(aIndex < mQuotesCount, "out of range");
  972.     return mQuotes + (aIndex * 2);
  973.   }
  974.   const nsString* CloseQuoteAt(PRUint32 aIndex) const
  975.   {
  976.     NS_ASSERTION(aIndex < mQuotesCount, "out of range");
  977.     return mQuotes + (aIndex * 2 + 1);
  978.   }
  979.   nsresult  GetQuotesAt(PRUint32 aIndex, nsString& aOpen, nsString& aClose) const {
  980.     if (aIndex < mQuotesCount) {
  981.       aIndex *= 2;
  982.       aOpen = mQuotes[aIndex];
  983.       aClose = mQuotes[++aIndex];
  984.       return NS_OK;
  985.     }
  986.     return NS_ERROR_ILLEGAL_VALUE;
  987.   }
  988.  
  989.   nsresult  AllocateQuotes(PRUint32 aCount) {
  990.     if (aCount != mQuotesCount) {
  991.       DELETE_ARRAY_IF(mQuotes);
  992.       if (aCount) {
  993.         mQuotes = new nsString[aCount * 2];
  994.         if (! mQuotes) {
  995.           mQuotesCount = 0;
  996.           return NS_ERROR_OUT_OF_MEMORY;
  997.         }
  998.       }
  999.       mQuotesCount = aCount;
  1000.     }
  1001.     return NS_OK;
  1002.   }
  1003.  
  1004.   nsresult  SetQuotesAt(PRUint32 aIndex, const nsString& aOpen, const nsString& aClose) {
  1005.     if (aIndex < mQuotesCount) {
  1006.       aIndex *= 2;
  1007.       mQuotes[aIndex] = aOpen;
  1008.       mQuotes[++aIndex] = aClose;
  1009.       return NS_OK;
  1010.     }
  1011.     return NS_ERROR_ILLEGAL_VALUE;
  1012.   }
  1013.  
  1014. protected:
  1015.   PRUint32            mQuotesCount;
  1016.   nsString*           mQuotes;
  1017. };
  1018.  
  1019. struct nsStyleContent: public nsStyleStruct {
  1020.   nsStyleContent(void);
  1021.   nsStyleContent(const nsStyleContent& aContent);
  1022.   ~nsStyleContent(void);
  1023.  
  1024.   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Content)
  1025.  
  1026.   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
  1027.     return aContext->AllocateFromShell(sz);
  1028.   }
  1029.   void Destroy(nsPresContext* aContext) {
  1030.     this->~nsStyleContent();
  1031.     aContext->FreeToShell(sizeof(nsStyleContent), this);
  1032.   };
  1033.  
  1034.   nsChangeHint CalcDifference(const nsStyleContent& aOther) const;
  1035. #ifdef DEBUG
  1036.   static nsChangeHint MaxDifference();
  1037. #endif
  1038.  
  1039.   PRUint32  ContentCount(void) const  { return mContentCount; } // [reset]
  1040.  
  1041.   const nsStyleContentData& ContentAt(PRUint32 aIndex) const {
  1042.     NS_ASSERTION(aIndex < mContentCount, "out of range");
  1043.     return mContents[aIndex];
  1044.   }
  1045.  
  1046.   nsStyleContentData& ContentAt(PRUint32 aIndex) {
  1047.     NS_ASSERTION(aIndex < mContentCount, "out of range");
  1048.     return mContents[aIndex];
  1049.   }
  1050.  
  1051.   nsresult AllocateContents(PRUint32 aCount);
  1052.  
  1053.   PRUint32  CounterIncrementCount(void) const { return mIncrementCount; }  // [reset]
  1054.   const nsStyleCounterData* GetCounterIncrementAt(PRUint32 aIndex) const {
  1055.     NS_ASSERTION(aIndex < mIncrementCount, "out of range");
  1056.     return &mIncrements[aIndex];
  1057.   }
  1058.  
  1059.   nsresult  AllocateCounterIncrements(PRUint32 aCount) {
  1060.     if (aCount != mIncrementCount) {
  1061.       DELETE_ARRAY_IF(mIncrements);
  1062.       if (aCount) {
  1063.         mIncrements = new nsStyleCounterData[aCount];
  1064.         if (! mIncrements) {
  1065.           mIncrementCount = 0;
  1066.           return NS_ERROR_OUT_OF_MEMORY;
  1067.         }
  1068.       }
  1069.       mIncrementCount = aCount;
  1070.     }
  1071.     return NS_OK;
  1072.   }
  1073.  
  1074.   nsresult  SetCounterIncrementAt(PRUint32 aIndex, const nsString& aCounter, PRInt32 aIncrement) {
  1075.     if (aIndex < mIncrementCount) {
  1076.       mIncrements[aIndex].mCounter = aCounter;
  1077.       mIncrements[aIndex].mValue = aIncrement;
  1078.       return NS_OK;
  1079.     }
  1080.     return NS_ERROR_ILLEGAL_VALUE;
  1081.   }
  1082.  
  1083.   PRUint32  CounterResetCount(void) const { return mResetCount; }  // [reset]
  1084.   const nsStyleCounterData* GetCounterResetAt(PRUint32 aIndex) const {
  1085.     NS_ASSERTION(aIndex < mResetCount, "out of range");
  1086.     return &mResets[aIndex];
  1087.   }
  1088.  
  1089.   nsresult  AllocateCounterResets(PRUint32 aCount) {
  1090.     if (aCount != mResetCount) {
  1091.       DELETE_ARRAY_IF(mResets);
  1092.       if (aCount) {
  1093.         mResets = new nsStyleCounterData[aCount];
  1094.         if (! mResets) {
  1095.           mResetCount = 0;
  1096.           return NS_ERROR_OUT_OF_MEMORY;
  1097.         }
  1098.       }
  1099.       mResetCount = aCount;
  1100.     }
  1101.     return NS_OK;
  1102.   }
  1103.  
  1104.   nsresult  SetCounterResetAt(PRUint32 aIndex, const nsString& aCounter, PRInt32 aValue) {
  1105.     if (aIndex < mResetCount) {
  1106.       mResets[aIndex].mCounter = aCounter;
  1107.       mResets[aIndex].mValue = aValue;
  1108.       return NS_OK;
  1109.     }
  1110.     return NS_ERROR_ILLEGAL_VALUE;
  1111.   }
  1112.  
  1113.   nsStyleCoord  mMarkerOffset;  // [reset]
  1114.  
  1115. protected:
  1116.   PRUint32            mContentCount;
  1117.   nsStyleContentData* mContents;
  1118.  
  1119.   PRUint32            mIncrementCount;
  1120.   nsStyleCounterData* mIncrements;
  1121.  
  1122.   PRUint32            mResetCount;
  1123.   nsStyleCounterData* mResets;
  1124. };
  1125.  
  1126. struct nsStyleUIReset: public nsStyleStruct {
  1127.   nsStyleUIReset(void);
  1128.   nsStyleUIReset(const nsStyleUIReset& aOther);
  1129.   ~nsStyleUIReset(void);
  1130.  
  1131.   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_UIReset)
  1132.  
  1133.   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
  1134.     return aContext->AllocateFromShell(sz);
  1135.   }
  1136.   void Destroy(nsPresContext* aContext) {
  1137.     this->~nsStyleUIReset();
  1138.     aContext->FreeToShell(sizeof(nsStyleUIReset), this);
  1139.   };
  1140.  
  1141.   nsChangeHint CalcDifference(const nsStyleUIReset& aOther) const;
  1142. #ifdef DEBUG
  1143.   static nsChangeHint MaxDifference();
  1144. #endif
  1145.  
  1146.   PRUint8   mUserSelect;      // [reset] (selection-style)
  1147.   PRUint8   mForceBrokenImageIcon; // [reset]  (0 if not forcing, otherwise forcing)
  1148. };
  1149.  
  1150. struct nsCursorImage {
  1151.   nsCOMPtr<imgIRequest> mImage;
  1152.   PRBool mHaveHotspot;
  1153.   float mHotspotX, mHotspotY;
  1154.  
  1155.   nsCursorImage();
  1156. };
  1157.  
  1158. struct nsStyleUserInterface: public nsStyleStruct {
  1159.   nsStyleUserInterface(void);
  1160.   nsStyleUserInterface(const nsStyleUserInterface& aOther);
  1161.   ~nsStyleUserInterface(void);
  1162.  
  1163.   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_UserInterface)
  1164.  
  1165.   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
  1166.     return aContext->AllocateFromShell(sz);
  1167.   }
  1168.   void Destroy(nsPresContext* aContext) {
  1169.     this->~nsStyleUserInterface();
  1170.     aContext->FreeToShell(sizeof(nsStyleUserInterface), this);
  1171.   };
  1172.  
  1173.   nsChangeHint CalcDifference(const nsStyleUserInterface& aOther) const;
  1174. #ifdef DEBUG
  1175.   static nsChangeHint MaxDifference();
  1176. #endif
  1177.  
  1178.   PRUint8   mUserInput;       // [inherited]
  1179.   PRUint8   mUserModify;      // [inherited] (modify-content)
  1180.   PRUint8   mUserFocus;       // [inherited] (auto-select)
  1181.   
  1182.   PRUint8   mCursor;          // [inherited] See nsStyleConsts.h
  1183.  
  1184.   PRUint32 mCursorArrayLength;
  1185.   nsCursorImage *mCursorArray;// [inherited] The specified URL values
  1186.                               //   and coordinates.  Takes precedence over
  1187.                               //   mCursor.  Zero-length array is represented
  1188.                               //   by null pointer.
  1189.  
  1190.   // Does not free mCursorArray; the caller is responsible for calling
  1191.   // |delete [] mCursorArray| first if it is needed.
  1192.   void CopyCursorArrayFrom(const nsStyleUserInterface& aSource);
  1193. };
  1194.  
  1195. struct nsStyleXUL : public nsStyleStruct {
  1196.   nsStyleXUL();
  1197.   nsStyleXUL(const nsStyleXUL& aSource);
  1198.   ~nsStyleXUL();
  1199.  
  1200.   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_XUL)
  1201.  
  1202.   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
  1203.     return aContext->AllocateFromShell(sz);
  1204.   }
  1205.   void Destroy(nsPresContext* aContext) {
  1206.     this->~nsStyleXUL();
  1207.     aContext->FreeToShell(sizeof(nsStyleXUL), this);
  1208.   };
  1209.  
  1210.   nsChangeHint CalcDifference(const nsStyleXUL& aOther) const;
  1211. #ifdef DEBUG
  1212.   static nsChangeHint MaxDifference();
  1213. #endif
  1214.   
  1215.   float         mBoxFlex;               // [reset] see nsStyleConsts.h
  1216.   PRUint32      mBoxOrdinal;            // [reset] see nsStyleConsts.h
  1217.   PRUint8       mBoxAlign;              // [reset] see nsStyleConsts.h
  1218.   PRUint8       mBoxDirection;          // [reset] see nsStyleConsts.h
  1219.   PRUint8       mBoxOrient;             // [reset] see nsStyleConsts.h
  1220.   PRUint8       mBoxPack;               // [reset] see nsStyleConsts.h
  1221. };
  1222.  
  1223. struct nsStyleColumn : public nsStyleStruct {
  1224.   nsStyleColumn();
  1225.   nsStyleColumn(const nsStyleColumn& aSource);
  1226.   ~nsStyleColumn();
  1227.  
  1228.   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Column)
  1229.   
  1230.   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
  1231.     return aContext->AllocateFromShell(sz);
  1232.   }
  1233.   void Destroy(nsPresContext* aContext) {
  1234.     this->~nsStyleColumn();
  1235.     aContext->FreeToShell(sizeof(nsStyleColumn), this);
  1236.   };
  1237.  
  1238.   nsChangeHint CalcDifference(const nsStyleColumn& aOther) const;
  1239. #ifdef DEBUG
  1240.   static nsChangeHint MaxDifference();
  1241. #endif
  1242.  
  1243.   PRUint32     mColumnCount; // [reset] see nsStyleConsts.h
  1244.   nsStyleCoord mColumnWidth; // [reset]
  1245.   nsStyleCoord mColumnGap;   // [reset]
  1246. };
  1247.  
  1248. #ifdef MOZ_SVG
  1249. enum nsStyleSVGPaintType {
  1250.   eStyleSVGPaintType_None = 0,
  1251.   eStyleSVGPaintType_Color,
  1252.   eStyleSVGPaintType_Server
  1253. };
  1254.  
  1255. struct nsStyleSVGPaint
  1256. {
  1257.   nsStyleSVGPaintType mType;
  1258.   union {
  1259.     nscolor mColor;
  1260.     nsIURI *mPaintServer;
  1261.   } mPaint;
  1262.  
  1263.   // empty constructor to keep Sun compiler happy
  1264.   nsStyleSVGPaint() {}
  1265.   ~nsStyleSVGPaint(); 
  1266.   nsStyleSVGPaint& operator=(const nsStyleSVGPaint& aOther);
  1267.   PRBool operator==(const nsStyleSVGPaint& aOther) const; 
  1268.  
  1269.   PRBool operator!=(const nsStyleSVGPaint& aOther) const {
  1270.     return !(*this == aOther);
  1271.   }
  1272. };
  1273.  
  1274. struct nsStyleSVG : public nsStyleStruct {
  1275.   nsStyleSVG();
  1276.   nsStyleSVG(const nsStyleSVG& aSource);
  1277.   ~nsStyleSVG();
  1278.  
  1279.   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_SVG)
  1280.  
  1281.   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
  1282.     return aContext->AllocateFromShell(sz);
  1283.   }
  1284.   void Destroy(nsPresContext* aContext) {
  1285.     this->~nsStyleSVG();
  1286.     aContext->FreeToShell(sizeof(nsStyleSVG), this);
  1287.   };
  1288.  
  1289.   nsChangeHint CalcDifference(const nsStyleSVG& aOther) const;
  1290. #ifdef DEBUG
  1291.   static nsChangeHint MaxDifference();
  1292. #endif
  1293.  
  1294.   nsStyleSVGPaint  mFill;             // [inherited]
  1295.   nsStyleSVGPaint  mStroke;           // [inherited]
  1296.   nsCOMPtr<nsIURI> mMarkerEnd;        // [inherited]
  1297.   nsCOMPtr<nsIURI> mMarkerMid;        // [inherited]
  1298.   nsCOMPtr<nsIURI> mMarkerStart;      // [inherited]
  1299.   nsStyleCoord    *mStrokeDasharray;  // [inherited]
  1300.  
  1301.   nsStyleCoord     mStrokeDashoffset; // [inherited]
  1302.   nsStyleCoord     mStrokeWidth;      // [inherited]
  1303.  
  1304.   float            mFillOpacity;      // [inherited]
  1305.   float            mStrokeMiterlimit; // [inherited]
  1306.   float            mStrokeOpacity;    // [inherited]
  1307.  
  1308.   PRUint32         mStrokeDasharrayLength;
  1309.   PRUint8          mClipRule;         // [inherited]
  1310.   PRUint8          mFillRule;         // [inherited] see nsStyleConsts.h
  1311.   PRUint8          mPointerEvents;    // [inherited] see nsStyleConsts.h
  1312.   PRUint8          mShapeRendering;   // [inherited] see nsStyleConsts.h
  1313.   PRUint8          mStrokeLinecap;    // [inherited] see nsStyleConsts.h
  1314.   PRUint8          mStrokeLinejoin;   // [inherited] see nsStyleConsts.h
  1315.   PRUint8          mTextAnchor;       // [inherited] see nsStyleConsts.h
  1316.   PRUint8          mTextRendering;    // [inherited] see nsStyleConsts.h
  1317. };
  1318.  
  1319. struct nsStyleSVGReset : public nsStyleStruct {
  1320.   nsStyleSVGReset();
  1321.   nsStyleSVGReset(const nsStyleSVGReset& aSource);
  1322.   ~nsStyleSVGReset();
  1323.  
  1324.   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_SVGReset)
  1325.   
  1326.   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
  1327.     return aContext->AllocateFromShell(sz);
  1328.   }
  1329.   void Destroy(nsPresContext* aContext) {
  1330.     this->~nsStyleSVGReset();
  1331.     aContext->FreeToShell(sizeof(nsStyleSVGReset), this);
  1332.   };
  1333.  
  1334.   nsChangeHint CalcDifference(const nsStyleSVGReset& aOther) const;
  1335. #ifdef DEBUG
  1336.   static nsChangeHint MaxDifference();
  1337. #endif
  1338.  
  1339.   nsStyleSVGPaint  mStopColor;        // [reset]
  1340.   nsCOMPtr<nsIURI> mClipPath;         // [reset]
  1341.   float            mStopOpacity;      // [reset]
  1342.   PRUint8          mDominantBaseline; // [reset] see nsStyleConsts.h
  1343. };
  1344. #endif
  1345.  
  1346.  
  1347. #define BORDER_PRECEDENT_EQUAL  0
  1348. #define BORDER_PRECEDENT_LOWER  1
  1349. #define BORDER_PRECEDENT_HIGHER 2
  1350.  
  1351. struct nsBorderEdges;
  1352.  
  1353. /** an encapsulation of border edge info */
  1354. struct nsBorderEdge
  1355. {
  1356.   /** the thickness of the edge */
  1357.   nscoord mWidth;
  1358.   /** the length of the edge */
  1359.   nscoord mLength;
  1360.   nscolor mColor;
  1361.   /** if this edge is an outside edge, the border infor for the adjacent inside object */
  1362.   nsBorderEdges * mInsideNeighbor;
  1363.   PRUint8 mStyle;  
  1364.   /** which side does this edge represent? */
  1365.   PRUint8 mSide;
  1366.  
  1367.   nsBorderEdge();
  1368. };
  1369.  
  1370. inline nsBorderEdge::nsBorderEdge()
  1371. {
  1372.   mWidth=0;
  1373.   mLength=0;
  1374.   mStyle=NS_STYLE_BORDER_STYLE_NONE;
  1375.   mColor=0;
  1376.   mSide=NS_SIDE_LEFT;
  1377.   mInsideNeighbor = nsnull;
  1378. }
  1379.  
  1380. /** an encapsulation of a border defined by its edges 
  1381.   * owner of this struct is responsible for freeing any data stored in mEdges
  1382.   */
  1383. struct nsBorderEdges
  1384. {
  1385.   nsVoidArray  mEdges[4];
  1386.   nsMargin     mMaxBorderWidth;
  1387.   PRPackedBool mOutsideEdge;
  1388.  
  1389.   nsBorderEdges();
  1390. };
  1391.  
  1392. inline nsBorderEdges::nsBorderEdges()
  1393. {
  1394.   mMaxBorderWidth.SizeTo(0,0,0,0);
  1395.   mOutsideEdge = PR_TRUE;
  1396. }
  1397.  
  1398. #endif /* nsStyleStruct_h___ */
  1399.